#include<bits/stdc++.h>
using namespace std;
int main(){
	ifstream fin("candy.in");
	ofstream fout("candy.out");
	int n,l,r,mid,ans=-1;
	fin>>n>>l>>r;
	for(int i=l;i<=l+n&&i<=r;i++){
		ans=max(ans,i%n);
	}
	fout<<ans;
	fin.close();
	fout.close();
	return 0;
}
